package com.remiss.seckilldemo.utils;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Component;

/**
 * MD5工具类
 */
@Component
public class MD5Util {
    public static String md5(String src){
        return DigestUtils.md5Hex(src);
    }

    private static final String salt = "1a2c3b4d";

    public static  String inputPass(String inputPass){
        String str = salt.charAt(1) + salt.charAt(2) + inputPass + salt.charAt(5);
        return md5(str);
    }
    public  static String fromPassToDBPass(String pass,String salt){
        String str = salt.charAt(1) + salt.charAt(2) + pass + salt.charAt(5);
        return md5(str);

    }
    public static String inputPassToDBPass(String inputPass,String salt){
        String fromPass = inputPass(inputPass);
        String dbPass = fromPassToDBPass(fromPass,salt);
        return dbPass;
    }

}
